package updown.data;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import updown.service.task.ScheduleTaskService;

/**
 * <p>Title: updown.data </p>
 * <p>Description:updown: - 服务启动成功的 任务 </p>
 *
 * @Author:jiangkaixin
 * @Date:1/5/2022
 * @Version: 1.0
 */
@Slf4j
@Component
public class ServiceStartListener implements ApplicationListener<ApplicationReadyEvent> {
    @Autowired
    private ScheduleTaskService scheduleTaskService;

    /**
     *
     * @param event
     */
    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        log.info("服务启动，查询数据中保存的 定时任务");
        scheduleTaskService.fillScheduleMapAfterRestart();
    }
}
